12 Jan
Open Flash Chart II – OFC Object Creators
Thought I would try and make things a little more flexible. In doing so, two new OFC Object creators came to life. You all may recall the very basic:
open_flash_chart_object(600,300,'/test_it/graph_test')
And maybe not, well either way, I am going to describe its functionality here plus the functionality of the two new object creators.
open_flash_chart_object()
Usage:
This method returns only the graph html:
@graph = open_flash_chart_object(....)
Arguments
- width (required)
- height (required)
- url (required)
- use_swfobject (optional and defaults to true)
- base (optional and defaults to "/")
- swf_file_name (optional and defaults to "open-flash-chart.swf")
open_flash_chart_object_and_div_name()
Usage:
This method will return, not only the html for the graph but also the div_name for use with javascript manipulation:
@graph, @div_name = open_flash_chart_object_and_div_name(...)
Arguments
- width (required)
- height (required)
- url (required)
- use_swfobject (optional and defaults to true)
- base (optional and defaults to "/")
- swf_file_name (optional and defaults to "open-flash-chart.swf")
open_flash_chart_object_from_hash()
Usage:
This method will return the graph html, but gives you absolute control over quite a few things, most importantly div_name.
@graph = open_flash_chart_object_from_hash(...)
Additional Usage:
@graph = open_flash_chart_object_from_hash("/test_it/graph_code", :div_name => 'my_div_name', :width => 600)
@graph = open_flash_chart_object_from_hash("/test_it/graph_code", :base => '/projects', :height => 600)
Arguments
- url (required)
- options (optional)
- div_name (defaults to "flash_content_[random string]")
- base (defaults to "/")
- swf_file_name (defaults to "open-flash-chart.swf")
- width (defaults to 550)
- height (defaults to 300)
- protocol (defaults to "http")
- obj_id (defaults to "chart_[random string]")
Well, there it is, good luck and have fun.
28 Responses
to “Open Flash Chart II – OFC Object Creators”
Sorry, comments for this entry are closed at this time.
Hi
Unsure where else to post any questions about the OFC I figured I would try here. If I am wrong please point me to the correct location.
I am a beginner but I have a basic test_it controller up and running. When I tried to integrate it into some existing code I came up against some issues.
First all errors now see to result in
"undefined method `rewrite’ for "%2Fhome%2Fgraph_code":String"
It took me a while to figure out that the error was some where else but once I figured out that I was able to debug.
It seems in my code I had some non-RESTful link_to statements which were previously working:
<filter:code attributes=lang="ruby">
<%= link_to ‘Add workout’, {:controller => ‘traininglogs’ , :action => :new } %>
< /filter:code>
Once I changed this to :
<filter:code attributes=lang="ruby">
<%= link_to ‘Add workout’, new_traininglog_path %>
< /filter:code>
This error disappeared. Why would the former syntax be an issue?
Unfortunately this did not completely fix my code. I also had a similar syntax but inside a loop
<filter:code attributes=lang="ruby">
<% @traininglogs.sort_by{ |i| i[:dateandtime]}.reverse.each do |traininglog| %>
<tr>
<td><%=h traininglog.duration %></td>
<td><%= link_to ‘Edit’, {:controller => ‘traininglogs’ , :action => :edit , :id => traininglog.id } %></td>
</tr>
<% end %>
< /filter:code>
I cannot for the life of me figure out how to "correct" this syntax.
I tried
<filter:code attributes=lang="ruby">
<td><%= link_to ‘Edit’, edit_traininglog_path %></td>
< /filter:code>
and 101 other combinations but I cannot get remove the error (same as above)
Any ideas or thoughts?
Good work on the code !
@diarmuid – this is fine – I am not sure this is OFC related, but nevertheless –
The basics:
1) What version of rails ?
2) Are you using the latest version of OFC II ?
As for the edit_traininglog_path(), you need to pass in the object that will require editing – edit_traininglog_path(traininglog).
I am not sure how the OFC plugin would be effecting this? Can you post the output of rake routes?
Also, when you use filter:code, make sure to remove the space between < and /filter:code> at the end of your code blocks 😉
Good luck, let me know what you find.
Charlie
I am using Rails 2.2.2 on Mac OSX 10.5.6. I installed OFC from git 2 days ago and according to the readme it’s "OpenFlashChart Version 2.0.0 11/14/2008 "
I was passing the traininglog as an argument but that didn’t work either.
The routes is one area that I am not confident in so it’s quite possible the error is there
<filter:code>
$ rake routes
(in /Users/diarmuid/Documents/Rails/coachconnect)
root / {:controller=>"home", :action=>"index"}
logout /logout {:controller=>"sessions", :action=>"destroy"}
login /login {:controller=>"sessions", :action=>"new"}
register /register {:controller=>"users", :action=>"create"}
signup /signup {:controller=>"users", :action=>"new"}
users GET /users {:controller=>"users", :action=>"index"}
formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
POST /users {:controller=>"users", :action=>"create"}
POST /users.:format {:controller=>"users", :action=>"create"}
new_user GET /users/new {:controller=>"users", :action=>"new"}
formatted_new_user GET /users/new.:format {:controller=>"users", :action=>"new"}
edit_user GET /users/:id/edit {:controller=>"users", :action=>"edit"}
formatted_edit_user GET /users/:id/edit.:format {:controller=>"users", :action=>"edit"}
user GET /users/:id {:controller=>"users", :action=>"show"}
formatted_user GET /users/:id.:format {:controller=>"users", :action=>"show"}
PUT /users/:id {:controller=>"users", :action=>"update"}
PUT /users/:id.:format {:controller=>"users", :action=>"update"}
DELETE /users/:id {:controller=>"users", :action=>"destroy"}
DELETE /users/:id.:format {:controller=>"users", :action=>"destroy"}
session POST /session {:controller=>"sessions", :action=>"create"}
formatted_session POST /session.:format {:controller=>"sessions", :action=>"create"}
new_session GET /session/new {:controller=>"sessions", :action=>"new"}
formatted_new_session GET /session/new.:format {:controller=>"sessions", :action=>"new"}
edit_session GET /session/edit {:controller=>"sessions", :action=>"edit"}
formatted_edit_session GET /session/edit.:format {:controller=>"sessions", :action=>"edit"}
GET /session {:controller=>"sessions", :action=>"show"}
GET /session.:format {:controller=>"sessions", :action=>"show"}
PUT /session {:controller=>"sessions", :action=>"update"}
PUT /session.:format {:controller=>"sessions", :action=>"update"}
DELETE /session {:controller=>"sessions", :action=>"destroy"}
DELETE /session.:format {:controller=>"sessions", :action=>"destroy"}
athletes GET /athletes {:controller=>"athletes", :action=>"index"}
formatted_athletes GET /athletes.:format {:controller=>"athletes", :action=>"index"}
POST /athletes {:controller=>"athletes", :action=>"create"}
POST /athletes.:format {:controller=>"athletes", :action=>"create"}
new_athlete GET /athletes/new {:controller=>"athletes", :action=>"new"}
formatted_new_athlete GET /athletes/new.:format {:controller=>"athletes", :action=>"new"}
edit_athlete GET /athletes/:id/edit {:controller=>"athletes", :action=>"edit"}
formatted_edit_athlete GET /athletes/:id/edit.:format {:controller=>"athletes", :action=>"edit"}
athlete GET /athletes/:id {:controller=>"athletes", :action=>"show"}
formatted_athlete GET /athletes/:id.:format {:controller=>"athletes", :action=>"show"}
PUT /athletes/:id {:controller=>"athletes", :action=>"update"}
PUT /athletes/:id.:format {:controller=>"athletes", :action=>"update"}
DELETE /athletes/:id {:controller=>"athletes", :action=>"destroy"}
DELETE /athletes/:id.:format {:controller=>"athletes", :action=>"destroy"}
traininglogs GET /traininglogs {:controller=>"traininglogs", :action=>"index"}
formatted_traininglogs GET /traininglogs.:format {:controller=>"traininglogs", :action=>"index"}
POST /traininglogs {:controller=>"traininglogs", :action=>"create"}
POST /traininglogs.:format {:controller=>"traininglogs", :action=>"create"}
new_traininglog GET /traininglogs/new {:controller=>"traininglogs", :action=>"new"}
formatted_new_traininglog GET /traininglogs/new.:format {:controller=>"traininglogs", :action=>"new"}
edit_traininglog GET /traininglogs/:id/edit {:controller=>"traininglogs", :action=>"edit"}
formatted_edit_traininglog GET /traininglogs/:id/edit.:format {:controller=>"traininglogs", :action=>"edit"}
traininglog GET /traininglogs/:id {:controller=>"traininglogs", :action=>"show"}
formatted_traininglog GET /traininglogs/:id.:format {:controller=>"traininglogs", :action=>"show"}
PUT /traininglogs/:id {:controller=>"traininglogs", :action=>"update"}
PUT /traininglogs/:id.:format {:controller=>"traininglogs", :action=>"update"}
DELETE /traininglogs/:id {:controller=>"traininglogs", :action=>"destroy"}
DELETE /traininglogs/:id.:format {:controller=>"traininglogs", :action=>"destroy"}
coaches GET /coaches {:controller=>"coaches", :action=>"index"}
formatted_coaches GET /coaches.:format {:controller=>"coaches", :action=>"index"}
POST /coaches {:controller=>"coaches", :action=>"create"}
POST /coaches.:format {:controller=>"coaches", :action=>"create"}
new_coach GET /coaches/new {:controller=>"coaches", :action=>"new"}
formatted_new_coach GET /coaches/new.:format {:controller=>"coaches", :action=>"new"}
edit_coach GET /coaches/:id/edit {:controller=>"coaches", :action=>"edit"}
formatted_edit_coach GET /coaches/:id/edit.:format {:controller=>"coaches", :action=>"edit"}
coach GET /coaches/:id {:controller=>"coaches", :action=>"show"}
formatted_coach GET /coaches/:id.:format {:controller=>"coaches", :action=>"show"}
PUT /coaches/:id {:controller=>"coaches", :action=>"update"}
PUT /coaches/:id.:format {:controller=>"coaches", :action=>"update"}
DELETE /coaches/:id {:controller=>"coaches", :action=>"destroy"}
DELETE /coaches/:id.:format {:controller=>"coaches", :action=>"destroy"}
home / {:controller=>"home", :action=>"index"}
/:controller/:action/:id
/:controller/:action/:id.:format
</filter:code>
and just for completeness, here is the error :
<filter:code>
NoMethodError in Home#index
Showing app/views/home/index.html.erb where line #46 raised:
undefined method `rewrite’ for "%2Fhome%2Fgraph_code":String
Extracted source (around line #46):
43: <td><%=h traininglog.activity %></td>
44: <td><%=h traininglog.length %></td>
45: <td><%=h traininglog.duration %></td>
46: <td><%= link_to ‘Edit’, edit_traininglog_path %></td>
47: </tr>
48: <% end %>
49: </table>
RAILS_ROOT: /Users/diarmuid/Documents/Rails/coachconnect
Application Trace | Framework Trace | Full Trace
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:626:in `url_for’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `url_for’
(eval):16:in `edit_traininglog_path’
app/views/home/index.html.erb:46
app/views/home/index.html.erb:40:in `each’
app/views/home/index.html.erb:40
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in `render_for_file’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in `render_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:868:in `render_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1248:in `default_render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1254:in `perform_action_without_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in `perform_action_without_caching’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action’
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache’
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in `cache’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `process_without_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in `process_without_session_management_support’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in `process’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in `process’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:64
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in `handle_request’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:76:in `process’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:74:in `synchronize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:74:in `process’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:159:in `process_client’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `each’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `process_client’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `initialize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `new’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `initialize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `new’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:282:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `each’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/command.rb:212:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
script/server:3
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:626:in `url_for’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/url_helper.rb:85:in `url_for’
(eval):16:in `edit_traininglog_path’
app/views/home/index.html.erb:46
app/views/home/index.html.erb:40:in `each’
app/views/home/index.html.erb:40
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in `render_for_file’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in `render_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:868:in `render_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in `render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1248:in `default_render’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1254:in `perform_action_without_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in `call_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in `perform_action_without_caching’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action’
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache’
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in `cache’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `send’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in `process_without_filters’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in `process_without_session_management_support’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in `process’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in `process’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in `handle_request’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi’
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:76:in `process’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:74:in `synchronize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/rails.rb:74:in `process’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:159:in `process_client’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `each’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `process_client’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `initialize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `new’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `initialize’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `new’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:282:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `each’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:281:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/command.rb:212:in `run’
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in `load’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:64
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in’
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require’
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
script/server:3
Request
Parameters:
None
Show session dump
—
:return_to:
:user_id: 9
:csrf_id: 9260c4aabafa1933eb7be31c1ca026f2
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{"cookie"=>[],
"Content-Type"=>"text/html",
"Cache-Control"=>"no-cache"}
</filter:code>
It’s because of newest commit (afb727753d4895730ec24220ca831f73122251cf) – new creators use @url instance variable that’s restricted for rails. Just revert this commit and wait until it’s repaired.
Charlie
It seems there is either some problem with the the mac os version of rails or more likely , with my installation.
I setup rails on my linux machine and ran the server there and I get more sensible errors. I will work from there.
thanks and I’ll let you know how I get on
D
Spoke too soon. Problem remains on the linux machine
I’ll try Imanel’s recommendations
Or create evil twin of plugin with modified name of @url in "/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb" (just tested with @c_url and everything works fine now)
Sorry for spam – there are no "edit" option and I’m in work so thinking about 3 other things 😉
diff –git a/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb b/vendor/plugins/open_flash_cha
index 6c94cfd..7efe7c0 100644
— a/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb
+++ b/vendor/plugins/open_flash_chart/lib/open_flash_chart/open_flash_chart_object.rb
@@ -4,19 +4,19 @@ module OpenFlashChart
module Controller
def open_flash_chart_object(width, height, url, use_swfobject=true, base="/", swf_file_name="open-flash-chart.swf")
get_object_values(url)
– get_html(@url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id)
+ get_html(@c_url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id)
end
# if you want the div name back for working with js, this is the ticket
def open_flash_chart_object_and_div_name(width, height, url, use_swfobject=true, base="/", swf_file_name="open-flash-ch
get_object_values(url)
– html = get_html(@url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id)
+ html = get_html(@c_url, @div_name, base, swf_file_name, width, height, @protocol, @obj_id)
return [html, @div_name]
end
def open_flash_chart_object_from_hash(url, options={})
get_object_values(url)
– get_html(@url,
+ get_html(@c_url,
options[:div_name] || @div_name,
options[:base] || "/",
options[:swf_file_name] || "open-flash-chart.swf",
@@ -27,9 +27,9 @@ module OpenFlashChart
end
def get_object_values(url)
– @url = CGI::escape(url)
+ @c_url = CGI::escape(url)
# need something that will not be repeated on the same request
– @special_hash = Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{@url}"))[0..7]
+ @special_hash = Base64.encode64(Digest::SHA1.digest("#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{@c_url}"))[0..7
# only good characters for our div
@special_hash = @special_hash.gsub(/[^a-zA-Z0-9]/,rand(10).to_s)
@obj_id = "chart_#{@special_hash}" # some sequencing without all the work of tracking it
@Imanel – thanks for the help, I fixed with your suggestion and pushed to the repo.
@diarmuid – Give it a shot with the latest commit.
I changed @url to @ofc_url, hope it helps.
all working now. Thanks guys
Question for you, I have:
Multiple charts on one page, as per your 2008/8/4 entry
A periodically_call_remote statement that is intended to update my graphs with new data, which has an associated rjs file which is called correctly.
First question: Am I doing this in an unnecessary roundabout way where there’s something easier? Please explain the periodically_call_to_remote_ofc_load if it’s appropriate here.
Second question: How do I get at the data to update it? I hope this is something obvious I’m missing since I’m new to this, but I’m basically trying to get this example http://teethgrinder.co.uk/open-flash-chart-2/tutorial-js.php to work with auto-update.
I’m sure I could get it to work if I could get at the data as in teethgrinder’s example, so second question is first priority 🙂
Thanks for this great resource.
So,
the fourth time I looked at your AJAX example, I finally realized that it wasn’t just loading a second pre-built chart. Going off of that, and using periodically_call_to_remote_ofc_load I have what I’m looking for.
The problem I have now is with three charts on one page, they all load showing the same thing. I went away from your multiple charts on one page example because I think I need to use js_open_flash_chart_object in the view to the my OFC load periodical call. Please let me know if this is correct or not, and if there’s a way I can have multiple charts on the same page using js_open…
Thanks again
Update:
I looked over at teethgrinder’s tutorial:
http://teethgrinder.co.uk/open-flash-chart-2/adv-js-2-charts.php
It looks like I need to be able to override get-data and specify something different. I’m sure this is what your example with multiple charts on one page did behind the scenes, but is that same functionality available when using js_open_flash_chart_object in the view?
@golfer – I am not sure which example you are referring to, but let’s see if I can point you in the right direction –
In this example, all the charts are pre loaded on the page and the links just show/hide the right ones:
http://pullmonkey.com/2008/9/22/open-flash-chart-ii-javascript-part-2
In this example, the links actually go fetch data (get-data) from the specified url:
http://pullmonkey.com/2008/9/23/open-flash-chart-ii-javascript-part-3
Any luck with those?
@charlie
Looked over the links (again), but still am not sure why my charts aren’t loading correctly.
Problem: All three charts load the same content until they are refreshed. Right now, even though the first two are pie charts and the third is a bar chart, they both initially load the image of the bar chart until they are reloaded by clicking on the remote_ofc_load link, at which point they load their correct content.
View snip:
<filter:code attributes=lang="html">
<td>
<%= @chart1.js_open_flash_chart_object("div1", 250,200) %>
<br />
<%= @chart1.link_to_remote_ofc_load("refresh 1", "div1", "/example/chart1_code") %>
<br /><br />
<%= @chart2.js_open_flash_chart_object("div2", 250,200) %>
<br />
<%= @chart2.link_to_remote_ofc_load("refresh 2", "div2", "/example/chart2_code") %>
</td>
<td>
<br />
<%= @bar.js_open_flash_chart_object("div3", 100,300) %>
<br />
<%= @bar.periodically_call_to_remote_ofc_load("div3", "/example/bar_code", :frequency => 2.0) %>
</td>
</filter:code>
Controller snip:
<filter:code attributes=lang="ruby">
def index
…
@bar = bar_obj
…
end
def bar_obj
…
bar = OpenFlashChart.new
…
return bar
end
def bar_code
…
render :text => bar.to_s
end
</filter:code>
I know it doesn’t look too DRY with bar_code and bar_obj doing the same thing with one returning the code and the other the obj, but I was trying to see if some combination of the two would work. Let me know if you have any idea as to why all three initially load the same chart until refreshed.
@golfer – You are saying that @chart1, @chart2 and @bar are all showing the same graph?
Where are chart1 and chart2 defined?
Can you post the generated html of the graph before it is refreshed?
Yes, they are all showing the same graph. I think it has to do with the objects being named the same (open-flash-chart.swf). Here’s a trimmed down version of the code that works and the generated html before page is refreshed:
View:
<filter:code attributes=lang="html">
<%= javascript_include_tag :defaults, ‘swfobject’ %>
<%= @chart1.js_open_flash_chart_object("div1", 250,200) %>
<br />
<%= @chart1.link_to_remote_ofc_load("refresh1", "div1", "/test/chart1_code") %>
<br /><br />
<%= @chart2.js_open_flash_chart_object("div2", 250,200) %>
<br />
<%= @chart2.link_to_remote_ofc_load("refresh2", "div2", "/test/chart2_code") %>
</filter:code>
Controller:
<filter:code attributes=lang="ruby">
def index
@chart1 = chart1_obj
@chart2 = chart2_obj
respond_to do |format|
format.html
end
end
def chart1_code
# build chart1
render :text => chart.to_s
end
def chart1_obj
# build chart1
return chart
end
def chart2_code
# build chart2
render :text => chart.to_s
end
def chart2_obj
# build chart2
return chart
end
</filter:code>
HTML before refresh:
<filter:code attributes=lang="html">
<script type="text/javascript">
swfobject.embedSWF("/open-flash-chart.swf", "div1", "250", "200", "9.0.0");
</script>
<script type="text/javascript">
function ofc_ready() {
}
function open_flash_chart_data() {
return Object.toJSON(data);
}
function findSWF(movieName) {
if (navigator.appName.indexOf("Microsoft")!= -1) {
return window[movieName];
} else {
return document[movieName];
}
}
var data = {"elements": [{"start-angle": 35, "type": "pie", "border": 2, "tip": "#val# of #total#<br>#percent#", "animate": true, "values": [{"value": 1, "label": "Unassigned"}, {"value": 2, "label": "Offline"}, {"value": 5, "label": "Online"}, {"value": 0, "label": "Away"}], "colours": ["#ff0000", "#d01f3c", "#8aa967", "#C79810"]}], "x_axis": null};
</script>
<div id="div1"></div>
<br />
<script type="text/javascript">
function reload_refresh1_div1() {
tmp_div1 = findSWF("div1");
new Ajax.Request(‘/test/chart1_code’, {
method : ‘get’,
onSuccess : function(obj) {tmp_div1.load(obj.responseText);},
onFailure : function(obj) {alert("Failed to request /test/chart1_code");}});
}
</script>
<a href="#" onclick="reload_refresh1_div1(); return false;">refresh1</a>
<br /><br />
<script type="text/javascript">
swfobject.embedSWF("/open-flash-chart.swf", "div2", "250", "200", "9.0.0");
</script>
<script type="text/javascript">
function ofc_ready() {
}
function open_flash_chart_data() {
return Object.toJSON(data);
}
function findSWF(movieName) {
if (navigator.appName.indexOf("Microsoft")!= -1) {
return window[movieName];
} else {
return document[movieName];
}
}
var data = {"elements": [{"start-angle": 35, "type": "pie", "border": 2, "tip": "#val# of #total#<br>#percent#", "animate": true, "values": [{"value": 1, "label": "Offense"}, {"value": 2, "label": "Defense"}], "colours": ["#856767", "#627ba2"]}], "x_axis": null};
</script>
<div id="div2"></div>
<br />
<script type="text/javascript">
function reload_refresh2_div2() {
tmp_div2 = findSWF("div2");
new Ajax.Request(‘/test/chart2_code’, {
method : ‘get’,
onSuccess : function(obj) {tmp_div2.load(obj.responseText);},
onFailure : function(obj) {alert("Failed to request /test/chart2_code");}});
}
</script>
<a href="#" onclick="reload_refresh2_div2(); return false;">refresh2</a>
</filter:code>
@golfer — how long ago did you get the ofc2 plugin? The generated code seems a bit outdated. Well, let me know.
@charlie – I pulled it within the last couple of weeks. Any idea why the charts are coming up the same? Does it do this in the version you have?
When was the last update to the plugin?
@charlie – Looks to me like the last thing went in on Jan 19th, and I have updated since then.
My open-flash-chart.swf in my public folder is 257KB.
Hi there,
I am having a problem with the plugin. I’ve followed the instructions to the letter, and the flash does appear in the view, but instead of showing me a graph, I get the following error in the flash element:
Open Flash Chart
IO ERROR
Loading test data
Error #2032: Stream Error. URL: http://monaqasat14.local/guru/dashboard/graph_code
in effect, when opening the URL in question, I get the following Rails error:
Open Flash Chart
IO ERROR
Loading test data
Error #2032: Stream Error. URL: http://monaqasat14.local/guru/dashboard/graph_code
The funny thing is that I can access http://monaqasat14.local/guru/dashboard without any problems???
Can anybody help?
Thanks.
BTW, I’m running Rails 2.2.2 and i just got the plugin today.
@khelal – Error 2032 is very general and indicates a problem in your rails code. When you encounter this error is there anything useful in your rails error logs … either development.log or production.log?
Can OFC make log plots? I need to make plots where the y-axis is log based and the x-axis is normal.
Thanks,
RPR
@Rob R – you can set the labels yourself, as text. "10", "100", "1000", etc. Then you will need to do a little extra work to display points where needed to correspond with the text values you set for the y-axis.
Hi Charlie,
I’m seeing the same thing as @Golfer & I was wondering if that was ever resolved. I created three test charts and loaded each. The image of the last chart is shown for all graphs until I hit the refresh link. (I was going to try and use this to get around my other issue. 🙂 )
Thanks,
Ed
Well, This may or may not be the correct way to implement this feature, but I’ve had some success in displaying multiple graphs on a page by creating a custom method that is a modified version of js_open_flash_chart_object.
So in my copy of the ofc_ajax.rb file – in the lib/open_flash_chart directory of the plugin, I’ve just added another method that looks like:
<filter:code attributes=lang="ruby">
def js_open_flash_chart_object_mult(div_name, width, height, base="/")
data_name = "#{div_name.gsub(" ","_")}"
<<-OUTPUT
<script type="text/javascript">
swfobject.embedSWF("#{base}open-flash-chart.swf", "#{div_name}", "#{width}", "#{height}", "9.0.0", "expressInstall.swf", {"get-data":"get_data_#{data_name}"});
function get_data_#{data_name}()
{
var data = #{self.render};
return Object.toJSON(data);
}
</script>
<div id="#{div_name}"></div>
OUTPUT
end
< /filter:code>
This is based off of the ofc example found here:
http://teethgrinder.co.uk/open-flash-chart-2/adv-js-2-charts.php
don’t know if this is the best way / right way to do this, but it seems to be working, at least for now.
I can call this method like:
<filter:code attributes=lang="ruby">
<% @charts.each_with_index do |chart, i| %>
<%= chart.js_open_flash_chart_object_mult("another_chart_js_#{i+1}", 550,300) %>
<% end %>
< /filter:code>
I think a better name is in order, but perhaps something like this could be useful to others.
I’m having trouble getting a yAxisRight working with proper steps.
It seems it wants to put every number between the range, regardless of what steps it set to
I’m using the following code in a scatterLine chart
y2 = YAxisRight.new
y2.set_range(35,55)
y2.set_steps(5)
y2.set_stroke(3)
y2.colour = ‘#FF0000’
y2.set_grid_colour(‘#FF00FF’)
chart.set_y_axis_right(y2)
and it’s putting 35, 36, 37, 38… up the y-right axis
Hi,
How can I set tooltip in following situation
In Rails App
I have a controll and write some codes like
def graph_code
chart = OpenFlashChart.new
line = Line.new
….
chart.add_element(line)
chart.set_tooltip(“#x_label#”)
…
end
How can I set the tip to the value of x_label
I get some like
…….
“tip”: “#x_label#”
….
And it just doesn’t work.
What should I do?
Thanks~